<style lang="less">
	page {
		background-color: #F7F7F7;
		padding-bottom: 50upx;
	}

	.container {
		padding-top: 30upx;
	}

	.head {
		background-color: #FFFFFF;
		padding: 28upx 50upx 28upx 28upx;
		box-sizing: border-box;
		display: flex;
		justify-content: space-between;
		align-items: center;

		.head_fr_fans {
			font-size: 20upx;
			font-weight: bold;
			color: #333333;
			line-height: 36upx;
		}
	}

	.head_fl {
		display: flex;
		align-items: center;

		.head_fl_img {
			width: 66upx;
			height: 66upx;
			border-radius: 50%;
			margin-right: 16upx;
		}

		.name {
			font-size: 24upx;
			font-weight: bold;
			color: #333333;
			line-height: 24upx;
			margin-bottom: 16upx;
		}

		.grade {
			display: inline-block;
			font-size: 18upx;
			font-weight: 500;
			color: #DBC291;
			line-height: 18upx;
			padding: 6upx 14upx;
			background: #322F2C;
			border-radius: 15upx;
		}
	}
	.capital{
		margin-top: 20upx;
		background-color: #FFFFFF;
		.capital_title{
			padding: 30upx;
			box-sizing: border-box;
			font-size: 30rpx;
			font-weight: bold;
			color: #333333;
			line-height: 36rpx;
		}
		.capital_foot{
			border-top: 0.5px solid #EDEDED;
			padding: 30upx;
		}
		.capital_foot_txt{
			display: inline-block;
			padding: 12upx 28upx;
			background: #DBC291;
			border-radius: 24upx;
			font-size: 22upx;
			font-weight: 500;
			color: #FFFFFF;
			line-height: 26upx;
		}
	}
	.capital_main{
		display: flex;
		flex-wrap: wrap;
		.capital_list{
			width: 33.33%;
			box-sizing: border-box;
			padding: 30upx 0;
			border-top: 1upx solid #EDEDED;
			border-right: 1upx solid #EDEDED;
			text-align: center;
			&:nth-of-type(3n){
				border-right: none;
			}
			.capital_list_money{
				font-size: 30rpx;
				font-family: "DINCond";
				font-weight: 400;
				color: #333333;
				line-height: 48rpx;
				margin-bottom: 20upx;
			}
			.capital_list_txt{
				font-size: 20rpx;
				font-weight: 500;
				color: #999999;
				line-height: 29rpx;
			}
		}
		.capital_list.active{
			width: 50%;
		}
		.capital_list.all{
			width: 100%;
		}
	}
	.foot{
		margin-top: 20upx;
		background-color: #FFFFFF;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 30upx;
		box-sizing: border-box;
		.foot_fl{
			font-size: 28rpx;
			font-weight: 500;
			color: #333333;
			line-height: 34rpx;
		}
		.foot_fr{
			width: 12rpx;
			height: 22rpx;
		}
	}
	.confirm{
		margin-top: 30upx;
		padding: 0 30upx;
		box-sizing: border-box;
		.btn{
			width: 100%;
			height: 70upx;
			background: #070506;
			border-radius: 35upx;
			font-size: 26upx;
			font-weight: bold;
			color: #FFFFFF;
			line-height: 70upx;
			text-align: center;
		}
	}
	
</style>


<template>

	<view class="container">
		<view class="head">
			<view class="head_fl">
				<image :src="http + obj.headIco" class="head_fl_img" mode="widthFix" v-if="obj.headIco != '' && obj.headIco != null" :webp="true"></image>
				<image src="https://static.xpandago.net/wechat/images/logo.png?x-oss-process=style/face-middle"
					class="head_fl_img" mode="widthFix" v-else></image>
				<view class="head_text">
					<view class="name">{{obj.username}}</view>
					<view class="grade">{{obj.memberTypeStr}}</view>
				</view>
			</view>
			<view class="head_fr">
				<view class="head_fr_fans" v-if="obj.code != '' && obj.code != null">邀请码：{{obj.code}}</view>
				<view class="head_fr_fans">粉丝数：{{obj.fsCount}}</view>
				<view class="head_fr_fans">积分余额：{{obj.availablePoint}}</view>
			</view>
		</view>
		<view class="capital">
			<view class="capital_title">账户资金明细</view>
			<view class="capital_main">
				<view class="capital_list all">
					<view class="capital_list_money">{{obj.allBalance}}</view>
					<view class="capital_list_txt">总账户</view>
				</view>
			</view>
			<view class="capital_main">
				<view class="capital_list" v-if="obj.shopType!='' && obj.shopType!=null" @tap="openUrl('/pages/newData/capitalAccount')">
					<view class="capital_list_money">{{obj.marketing}}</view>
					<view class="capital_list_txt">营销账户</view>
				</view>
				<view class="capital_list" :class="{'active':obj.shopType==null || obj.shopType==''}">
					<view class="capital_list_money">{{obj.giftAmount}}</view>
					<view class="capital_list_txt">充值款余额</view>
				</view>
				<view class="capital_list" :class="{'active':obj.shopType==null || obj.shopType==''}">
					<view class="capital_list_money">{{obj.balance}}</view>
					<view class="capital_list_txt">收益账户总额</view>
				</view>
			</view>
		</view>
		<view class="capital">
			<view class="capital_title">收益情况</view>
			<view class="capital_main">
				<view class="capital_list">
					<view class="capital_list_money">{{obj.dayPrice}}</view>
					<view class="capital_list_txt">今日收入</view>
				</view>
				<view class="capital_list">
					<view class="capital_list_money">{{obj.mouthPrice}}</view>
					<view class="capital_list_txt">本月收入</view>
				</view>
				<view class="capital_list">
					<view class="capital_list_money">{{obj.allPrice}}</view>
					<view class="capital_list_txt">累计收入</view>
				</view>
				<view class="capital_list">
					<view class="capital_list_money">{{obj.dayMoney}}</view>
					<view class="capital_list_txt">今日销售额</view>
				</view>
				<view class="capital_list">
					<view class="capital_list_money">{{obj.monthMoney}}</view>
					<view class="capital_list_txt">本月销售额</view>
				</view>
				<view class="capital_list">
					<view class="capital_list_money">{{obj.allMoney}}</view>
					<view class="capital_list_txt">累计销售额</view>
				</view>
				<view class="capital_list" @tap="openUrl('/pages/newData/capitalItem')">
					<view class="capital_list_money">{{obj.shopPrice}}</view>
					<view class="capital_list_txt">本月招商收益</view>
				</view>
				<view class="capital_list"></view>
				<view class="capital_list"></view>
			</view>
			<view class="capital_foot" v-if="obj.shopMsg != '' && obj.shopMsg != null">
				<view class="capital_foot_txt">{{obj.shopMsg}}</view>
			</view>
		</view>
		<view class="foot" @tap="openUrl('/pages/newData/capitalDetail')">
			<view class="foot_fl">资金明细</view>
			<image src="https://static.xpandago.net/wechat/images/right_fh.png" class="foot_fr" mode="widthFix"></image>
		</view>
		<view class="confirm">
			<view class="btn" @tap="openGoods">申请提现</view>
		</view>
	</view>

</template>

<script>
	import api from '@/common/api';
	import webView from '@/common/webView'
	export default {

		components: {},

		data() {

			return {
				token:'',
				obj:{},
				http:api.httpImg
			}
		},
		onLoad(options) {
			// this.token='eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiLmtYvor5XpnLgiLCJhdWRpZW5jZSI6ImUxMGFkYzM5NDliYTU5YWJiZTU2ZTA1N2YyMGY4ODNlIiwidXNlcl9pZCI6NzA0NjQsImNyZWF0ZWQiOjE2NTIzMjQ4MTQ5ODgsImV4cCI6MTY1NDkxNjgxNCwidXNlcl9ncm91cF9pZCI6bnVsbCwicGxhdGZvcm0iOm51bGx9.GN1nnXPFLjt8KUzcc5YptudMiNiWb2ydY5bZovPT7Cxo63fSC_dRMGW96PPFG2tix9ImlsiSQa16dF6OEBaasw'
			// uni.setStorageSync('token', this.token);
			// this.listTop()
			
			let code=this.GetQueryString('code');
			let that=this
			let userStr = navigator.userAgent
			if(Boolean(options.type) != false){
				this.token = uni.getStorageSync('token')
				that.listTop()
			}else if(code!=null && code !='' && code != undefined){
				this.loginCode(code)
			}else{
				if (userStr.indexOf('Android') !== -1) {
				  that.token = window.Android.getUserToken();
				  let token=that.token
				  uni.setStorageSync('token', token);
				  that.listTop()
				} else {
				  webView.callhandler('getUserToken', {}, (data) => {
					uni.setStorageSync('token', data);
				    that.token = data;
					that.listTop()
				  })
				}
			}
			
		},
		methods: {
			GetQueryString(name){
			    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
			    var r = window.location.search.substr(1).match(reg);
			    if(r!=null)return  unescape(r[2]); return null;
			},
			//返回xpa app
			openGoods(){
				let userStr = navigator.userAgent
				if (userStr.indexOf('Android') !== -1) {
					let params={type:'withdraw',value:''}
					window.Android.showInfoFromJs(JSON.stringify(params))
				} else {
				  webView.callhandler(
				    "JumpNativePage",
				    {
				  	Module: "WithdrawViewController",
				  	params: JSON.stringify({
				  	}),
				    },
				    (data) => {}
				  );
				  
				}
			},
			openUrl(url){
				uni.navigateTo({
					url:url
				})
			},
			async loginCode(code){
				const [err, res] = await api.loginCode({
						query: {
							code:code
						}
					 });
				 console.log(res)
				 if(res.data.code == 0){
					 let token=res.data.data
					 this.token=token
					 uni.setStorageSync('token', token);
					 this.listTop()
				 }else{
					 uni.showToast({
					 	title: res.data.msg,
					 	icon: 'none'
					 })
					if(res.data.code==100){
						uni.removeStorageSync('token');
						setTimeout(() => {
							uni.reLaunch({
							  url: "/pages/login/loginWechat"
							})
						}, 1000);
					}
				 }
			},
			//头部接口
			async listTop(){
				const [err, res] = await api.listTop({
					 header:{
						'Content-Type': 'application/json',
						'token': this.token
					 }
				 });
				 if(res.data.code == 0){
					 this.obj=res.data.data
				 }else{
					 uni.showToast({
					 	title: res.data.msg,
					 	icon: 'none'
					 })
				 }
			},
		},

	}
</script>
